//
//  CollectionViewCell.m
//  AirQuality
//
//  Created by Mac on 15/12/29.
//  Copyright © 2015年 Po. All rights reserved.
//

#import "CollectionViewCell.h"
#import "DrayImage.h"

@implementation CollectionViewCell

- (void)awakeFromNib {
    // Initialization code
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        NSArray * arrayOfViews = [[NSBundle mainBundle] loadNibNamed:@"CollectionViewCell" owner:self options:nil];
        if (arrayOfViews.count < 1) {
            return nil;
        }
        if (![[arrayOfViews objectAtIndex:0] isKindOfClass:[CollectionViewCell class]]) {
            return nil;
        }
        self = [arrayOfViews objectAtIndex:0];
    }
    return self;
}

- (void)drawHistogramWithData:(NSArray *)array withmax:(NSString *)max
{
    CGFloat count = 120.0/[max integerValue];
    for (NSUInteger i = 0; i < array.count; i ++) {
        CGFloat hight = [array[i] integerValue]*count;
        UIView * view = [[UIView alloc] initWithFrame:CGRectMake(6*i, 120-hight, 4, hight)];
        CGFloat value = [array[i] floatValue];
        view.backgroundColor = [RJTools getColorWithAirNum:value  type:@"AQI" alpha:1];
        [self addSubview:view];
    }
}

@end
